<template>
  <div>
    <el-card>
      <div>
        <el-form ref="elForm" :model="formData" :rules="rules" size="medium" label-width="100px">
          <el-form-item label="审批意见" prop="approveRemark">
            <el-input type="textarea" v-model="formData.approveRemark"></el-input>
          </el-form-item>
          <el-form-item>
            <el-button @click="cancel">取消</el-button>
            <el-button type="primary" @click="submitForm('elForm')">保存</el-button>
          </el-form-item>
        </el-form>
      </div>
    </el-card>
  </div>
</template>

<script>
  import { ajax } from "@/store/yg/common/utils";
  import { closeDialog } from "@/utils";

  export default {
    data() {
      return {
        formData: {},

        rules: {
          approveRemark: [{
            required: true,
            message: '请输入',
            trigger: 'blur'
          }]
        },
      };
    },
    mounted() {

      debugger
    },
    methods: {
      cancel() {
        closeDialog();
      },

      //数据校验
      submitForm(formName) {
        this.$refs[formName].validate(valid => {
          if (valid) {
            this.save();
          } else {
            console.log("数据校验失败，不允许提交");
            return false;
          }
        });
      },

      /**
       * 驳回申请人
       * */
      async save() {
        const ids = this.$store.state.edit.ids;
        const approveRemark = this.formData.approveRemark;
        const { code, data, message } = await ajax("rejectApplyUser", {
          ids: ids,
          approveRemark: approveRemark
        });
        if (code !== 200) {
          if (message) {
            this.$message.error(message);
          } else {
            this.$message.error("服务器异常");
          }
          return;
        }
        closeDialog();
        this.$message({
          type: "success",
          message: "操作成功！"
        });
      }
    }
  };
</script>


<style>

</style>
